<template>
  <div class="detail">
    <h3 class="art_h" v-text="newInfo.title"></h3>
    <div class="art_time">
      <span>发表时间: {{ newInfo.add_time|formatData }}</span>
      <span>点击次数:{{ newInfo.click }}</span>
    </div>
    <van-divider />
    <div class="content" v-html="newInfo.content"></div>
    <comment v-bind:comId="$route.params.id"></comment>
  </div>
</template>

<script>
import comment from '../../components/comment.vue'
export default {
  components: {
    comment
  },
  data() {
    return {
      newInfo: {}
    }
  },

  created() {
    this.getNewsInfo()
  },

  methods: {
    async getNewsInfo() {
      const { data: res } = await this.$axios.get(
        `/api/getnew/${this.$route.params.id}`
      )
      if (res.status !== 0) return this.$notify('获取失败')
      this.newInfo = res.message[0]
    }
  }
}
</script>

<style scoped lang='less'>
.detail {
  padding: 0 10px;
}
.art_h {
  color: #1989fa;
  font-size: 14px;
  line-height: 30px;
  text-align: center;
}
.art_time {
  display: flex;
  justify-content: space-between;
  span {
    font-size: 13px;
    color: #1989fa;
  }
}
/deep/.content p {
  color: #535353;
}
.van-divider {
  margin: 10px 0;
}
</style>
